<script setup>
import { onMounted, ref } from 'vue';
import ChatPage from './ChatPage.vue';
import { Link, Document, InfoFilled } from '@element-plus/icons-vue';

onMounted(() => {

})

const showAbout = ref(false);

// 打开 GitHub 仓库链接
const openGitHub = () => {
  window.open('https://gitee.com/tdc22331083/BuildMind', '_blank');
};

// 打开文档链接
const openDocs = () => {
  window.open('https://gitee.com/tdc22331083/BuildMind/blob/master/README.md', '_blank');
};
</script>

<template>
  <div class="build-mind-container">
    <div class="page-header">
      <div class="logo">
        <img src="../assets/logo.svg" alt="BuildMind Logo" class="logo-image" />
        <h1 class="logo-text">BuildMind</h1>
      </div>
      <div class="header-actions">
        <el-tooltip content="GitHub 仓库" placement="bottom">
          <el-button type="primary" :icon="Link" circle class="github-button" @click="openGitHub" />
        </el-tooltip>
        <el-tooltip content="文档" placement="bottom">
          <el-button type="primary" :icon="Document" circle class="docs-button" @click="openDocs" />
        </el-tooltip>
        <el-tooltip content="关于" placement="bottom">
          <el-button type="primary" :icon="InfoFilled" circle class="about-button" @click="showAbout = true" />
        </el-tooltip>
      </div>
    </div>

    <div class="main-content">
      <ChatPage />
    </div>

    <!-- 关于对话框 -->
    <el-dialog v-model="showAbout" title="关于 BuildMind" width="500px" align-center class="about-dialog">
      <div class="about-content">
        <img src="../assets/logo.svg" alt="BuildMind Logo" class="about-logo" />
        <h2>BuildMind</h2>
        <p class="about-description">
          BuildMind 是一个创新的低代码开发平台，致力于通过 AI 技术简化软件开发流程。
          只需提供自然语言需求描述，BuildMind 即可帮助您生成工作流、代码和部署文档。
        </p>
        <div class="version-info">
          <span>版本: 1.0.0</span>
        </div>
        <div class="tech-stack">
          <h3>技术栈</h3>
          <div class="tech-items">
            <el-tag effect="plain" class="tech-tag">Vue 3</el-tag>
            <el-tag effect="plain" class="tech-tag">Vite</el-tag>
            <el-tag effect="plain" class="tech-tag">Element Plus</el-tag>
            <el-tag effect="plain" class="tech-tag">Pinia</el-tag>
          </div>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<style scoped>
.build-mind-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f8fafc;
  overflow: hidden;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  z-index: 2;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-image {
  height: 36px;
  width: auto;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  color: #409eff;
  margin: 0;
  background: linear-gradient(90deg, #409eff, #67c23a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.github-button,
.docs-button,
.about-button {
  transition: transform 0.2s;
}

.github-button:hover,
.docs-button:hover,
.about-button:hover {
  transform: scale(1.05);
}

.main-content {
  flex: 1;
  overflow: hidden;
  padding: 16px;
}

/* 关于对话框 */
.about-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 0;
}

.about-logo {
  width: 80px;
  height: auto;
  margin-bottom: 16px;
}

.about-description {
  margin: 16px 0;
  color: #606266;
  line-height: 1.6;
}

.version-info {
  margin: 16px 0;
  color: #909399;
  font-size: 14px;
}

.tech-stack {
  margin-top: 24px;
  width: 100%;
}

.tech-stack h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: #303133;
}

.tech-items {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tech-tag {
  padding: 6px 12px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    padding: 12px 16px;
  }

  .logo-image {
    height: 28px;
  }

  .logo-text {
    font-size: 20px;
  }
}
</style>